package com.fzhucc.modules.lesson.domain;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.fzhucc.base.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.sql.Timestamp;

/**
* @description /
* @author yyg
* @date 2022-12-07
**/
@Entity
@Data
@Table(name="tb_lesson")
public class Lesson extends BaseEntity implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "`id`")
    @ApiModelProperty(value = "id")
    private Integer id;

    @Column(name = "`name`",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "课程名称")
    private String name;

    @Column(name = "`cover_url`")
    @ApiModelProperty(value = "课程封面")
    private String coverUrl;

    @Column(name = "`course_points`")
    @ApiModelProperty(value = "课程积分(学习此课程所需积分)")
    private Integer coursePoints;

    @Column(name = "`starttime`")
    @ApiModelProperty(value = "课程上线开始时间")
    private Timestamp starttime;

    @Column(name = "`hot`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "热度")
    private Integer hot;

    @Column(name = "`endtime`")
    @ApiModelProperty(value = "课程上线结束时间")
    private Timestamp endtime;

    @Column(name = "`is_unlimited_time`")
    @ApiModelProperty(value = "是否不限制上线开始结束时间 默认限制     0不限制(永久)   1限制")
    private Integer isUnlimitedTime;

    @Column(name = "`is_show`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "是否展示")
    private Integer isShow;

    @Column(name = "`is_delete`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "是否删除")
    private Integer isDelete;

    @Column(name = "`type`",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "课程分类")
    private String type;

    @Column(name = "`introduce`")
    @ApiModelProperty(value = "课程介绍")
    private String introduce;

    @Column(name = "`is_push`")
    @ApiModelProperty(value = "是否推送首页")
    private Integer isPush;

    @Column(name = "`sort`")
    @ApiModelProperty(value = "排序")
    private Integer sort;

    @ApiModelProperty(value = "地区划分 即什么地区看的到什么地区的数据,省的看到全部")
    @Column(name = "`org_area`",nullable = false)
    @NotNull
    public String orgArea;

    public void copy(Lesson source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}
